---
description: "Reference for Nitric's v0 Go library - Creates a reference to a secret in the secrets manager."
---

# Go - NewSecret()

Creates a reference to a secret in the secrets manager.

```go
import (
  "fmt"

  "github.com/nitrictech/go-sdk/nitric"
)

func main() {
  secret, err := nitric.NewSecret("secret-name").With(nitric.SecretPutting, nitric.SecretAccessing)
  if err != nil {
    return
  }

  nitric.Run()
}
```

## Parameters

<Properties>
  <Property name="name" required type="string">
    The unique name of this secret within the secrets manager. Subsequent calls
    to `NewSecret` with the same name will return the same object.
  </Property>
</Properties>

## Access

All Nitric resources provide access permissions you can use to specify the level of access your code needs to the resource. See here for details about infrastructure [security](/get-started/foundations/infrastructure/security).

### Available permissions:

---

**SecretPutting**

This permission allows your code to set a new latest value for a secret.

---

**SecretAccessing**

This permission allows your code to retrieve secret values.

---

## Examples

### Create a reference to a secret

```go
import (
  "fmt"

  "github.com/nitrictech/go-sdk/nitric"
)

func main() {
  secret, err := nitric.NewSecret("secret-name").With(nitric.SecretPutting, nitric.SecretAccessing)
  if err != nil {
    return
  }

  nitric.Run()
}
```

### See also

- [Secret.Put()](./secret-put)
- [Secret.Version()](./secret-version)
- [Secret.Latest()](./secret-latest)
- [Secret.Version().Access()](./secret-version-access)
